Skip to content

Check for undefined XRay Trace Id in AwsSdk Instrumentation #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 8, 2025

Conversation

liustve
Copy link
Contributor

@liustve liustve commented Jun 2, 2025

Issue #, if available:

There is a bug where an undefined XRay Trace id is injected into the headers. However, this bug is difficult to reproduce:
image

The header in the export request to error out:

Failed to sign/authenticate the given exported Span request to OTLP XRay endpoint with error: TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "X-Amzn-Trace-Id"

However it's unclear whether or not this is the root-cause, for now we will add a null-safety check to mitigate any potential future bugs with this code.

Description of changes:
Added null check before injecting AWSXRAY_TRACE_ID_HEADER

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@liustve liustve requested a review from a team as a code owner June 2, 2025 17:33
jj22ee
jj22ee previously approved these changes Jun 2, 2025
Copy link

@thpierce thpierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add unit tests for this case?

@liustve liustve force-pushed the fix-undefined-trace branch from fcb7b3c to 3b83b2b Compare June 3, 2025 09:23
@liustve liustve merged commit 241fa38 into aws-observability:main Jun 8, 2025
9 checks passed
jj22ee pushed a commit to jj22ee/aws-otel-js-instrumentation that referenced this pull request Jun 14, 2025
…rvability#187)

*Issue #, if available:*

There is a bug where an undefined XRay Trace id is injected into the
headers. However, this bug is difficult to reproduce:

![image](https://github.com/user-attachments/assets/8d2fdafb-60e3-4a3f-b59e-858183c8e47e)

The header in the export request to error out:
```
Failed to sign/authenticate the given exported Span request to OTLP XRay endpoint with error: TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "X-Amzn-Trace-Id"
```

However it's unclear whether or not this is the root-cause, for now we
will add a null-safety check to mitigate any potential future bugs with
this code.

*Description of changes:*
Added null check before injecting `AWSXRAY_TRACE_ID_HEADER`

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants